/**
 * 渲染部门名称下拉框
 */
function brName() {
    $.ajaxSettings.async = false;
    $.getJSON("/selectBr", function (dateA) {
        var options = "<option value='0'>请选择</option>"
        for (var i = 0; i < dateA.length; i++) {
            options = "<option value='" + dateA[i].id + "'>" + dateA[i].brName + "</option>";
            $("#brNameXiaLak").append(options);
        }
    })
    $.ajaxSettings.async = true;
}

/**
 * 渲染动态下拉框
 */
function posName() {
    $.ajaxSettings.async = false;
    $.getJSON("/selPosName", function (dateA) {
        var options = "<option value='0'>请选择</option>";
        for (var i = 0; i < dateA.length; i++) {
            options = "<option value='" + dateA[i].id + "' name='" + dateA[i].posType + "' id='" + dateA[i].posCode + "'>" + dateA[i].posName + "</option>";

            $("#posNameXiaLaK").append(options);
        }
    })
    $.ajaxSettings.async = true;
}

/**
 * 根据posName选择编号和职位分类
 */
function showCode() {
    let posCode = $("#posNameXiaLaK option:selected").attr("id");
    let posType = $("#posNameXiaLaK option:selected").attr("name")
    console.log(posType)
    console.log(posCode)
    $("#bianma").val(posCode)
    $("#fenlei").val(posType)
}

function addJob() {
    var brId = $(".brId").val();
    var joType = $(".joType").val();
    var joCount = $(".joCount").val();
    var posId = $(".posId").val();
    var registrant = $(".registrant").val();
    var startTime = $(".startTime").val();
    var endTime = $(".endTime").val();
    var jobDescribe = $(".jobDescribe").val();
    var jobRequire = $(".jobRequire").val();

    if (brId == "" || joType == "" || joCount == "" || posId == "" || registrant == "" || startTime == "" || endTime == "" || jobDescribe == "" || jobRequire == "") {
        alert("所有选项不能为空！")
        return;
    }


    let jsonA = {
        brId: brId,
        joType: joType,
        joCount: joCount,
        posId: posId,
        registrant: registrant,
        startTime: startTime,
        endTime: endTime,
        jobDescribe: jobDescribe,
        jobRequire: jobRequire
    }
    console.log(jsonA)
    $.ajaxSettings.async = false;
    $.get("/addJob", jsonA, function (dataA) {
        if (dataA == true) {
            alert("添加成功！")
            location.href = "wangzwfbgl";
        } else {
            alert("添加失败！")
            return;
        }
    })
    $.ajaxSettings.async = true;
}

//跳转到查询页面
function fanHui() {
    location.href = "wangzwfbgl";
}

